home *** CD-ROM | disk | FTP | other *** search
- property myChannel, myMusicList, myVolume, myPlayList, myDelay, myTime, myStatus
-
- on new me, channelP, delayP, musicListP
- set myChannel to channelP
- set myMusicList to musicListP
- set myPlayList to list(getAt(myMusicList, 1))
- compileMusicList(me)
- set myDelay to delayP
- return me
- end
-
- on setState me, activeState
- if activeState then
- set myTime to the ticks + (myDelay * 60)
- if getOne(the actorList, me) = 0 then
- append(the actorList, me)
- end if
- set myStatus to #fadeOut
- else
- if getOne(the actorList, me) > 0 then
- deleteAt(the actorList, getOne(the actorList, me))
- end if
- sound fadeOut myChannel, 60
- end if
- end
-
- on stepFrame me
- case myStatus of
- #play:
- if myTime > the ticks then
- exit
- else
- set myStatus to #fadeOut
- exit
- end if
- #start:
- puppetSound(myChannel, getAt(myPlayList, 1))
- set myTime to the ticks + (myDelay * 60)
- set myStatus to #fadeIn
- #fadeOut:
- if the volume of sound myChannel > 0 then
- set the volume of sound myChannel to the volume of sound myChannel - 15
- else
- unloadMember(getAt(myPlayList, 1))
- if count(myPlayList) = 1 then
- compileMusicList(me)
- else
- deleteAt(myPlayList, 1)
- end if
- set myStatus to #start
- end if
- #fadeIn:
- if the volume of sound myChannel < 255 then
- set the volume of sound myChannel to the volume of sound myChannel + 15
- else
- set myStatus to #play
- end if
- end case
- end
-
- on compileMusicList me
- set tempList to value(string(myMusicList))
- set firstItem to getAt(myPlayList, 1)
- set myPlayList to []
- deleteAt(tempList, getOne(tempList, firstItem))
- repeat while count(myPlayList) < (count(myMusicList) - 1)
- set i to random(count(tempList))
- append(myPlayList, getAt(tempList, i))
- deleteAt(tempList, i)
- end repeat
- addAt(myPlayList, 1 + random(count(myPlayList)), firstItem)
- end
-